import 'package:flutter_gex_news/model/MovieModel.dart';
import 'package:flutter_gex_news/service/service.dart';
import 'package:get/get.dart';

class MovieController extends GetxController{

  var isLoading = true.obs;
  var movieslist = <MovieModel>[].obs;

  @override
  void onInit() {
    // TODO: implement onInit
    fetchMovies();
    super.onInit();
  }

  void fetchMovies() async{
     try{
       isLoading(true);
       var movies = await ApiService.fetchMovies(scuess: (int statuscode, String message, json) {

       }, failure: (int statuscode) {

       });
       if(movies!= null){
         movieslist.assignAll(movies);
       }
     }catch(e){
        print(e);
     }finally{
       isLoading(false);
     }
  }
}